package cn.xshi.log.service.impl;

import cn.xshi.common.base.BaseService;
import cn.xshi.common.util.ExceptionUtil;
import cn.xshi.log.dao.LogLoginDao;
import cn.xshi.log.dto.LogLoginBrowserDTO;
import cn.xshi.log.form.LogLoginForm;
import cn.xshi.log.model.LogLogin;
import cn.xshi.log.service.LogLoginService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
* @Desc 登录日志 
* @Author 邓纯杰
* @CreateTime 2022-08-24 11:21:01
*/
@Service
public class LogLoginServiceImpl extends BaseService implements LogLoginService {

	@Resource
	private LogLoginDao logLoginDao;

	/**
	* 分页
	* @param logLoginForm
	* @return
	*/
	public List<LogLogin> getLogLoginListByCondition(LogLoginForm logLoginForm){
		try{
			return logLoginDao.getLogLoginListByCondition(logLoginForm);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
	}

	/**
	* 查询对象
	* @param id 
	* @return
	*/
	public LogLogin getLogLoginById(String id){
		try{
			LogLogin logLogin = logLoginDao.getLogLoginById(id);
			return logLogin;
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
	}

	/**
	* 添加
	* @param logLogin 
	* @return
	*/
	public int addLogLogin(LogLogin logLogin){
		int i = 0;
		try {
			i = logLoginDao.addLogLogin(logLogin);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	* 修改
	* @param logLogin 
	* @return
	*/
	public int updateLogLogin(LogLogin logLogin){
		int i = 0;
		try {
			i = logLoginDao.updateLogLogin(logLogin);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	* 修改（根据动态条件）
	* @param logLogin 
	* @return
	*/
	public int updateLogLoginBySelective(LogLogin logLogin){
		int i = 0;
		try {
			i = logLoginDao.updateLogLoginBySelective(logLogin);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	* 删除
	* @param condition 
	* @return
	*/
	public int delLogLogin(Map<String,Object> condition){
		int i = 0;
		try {
			i = logLoginDao.delLogLogin(condition);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	 * 浏览器分布报表统计
	 * @param condition
	 * @return
	 */
	public List<LogLoginBrowserDTO> getBrowserReport(Map<String, Object> condition){
		return logLoginDao.getBrowserReport(condition);
	}
}
